﻿using UnityEngine;
using System.Collections;

public class selectShip : MonoBehaviour
{

	//float scrollPos = 0.5f;

	Vector2 scrollPos ;
	Vector2 buildMenuScrollPosition;
	float MenuX;
	float MenuY;
	float MenuW;
	float MenuH;
	public Transform transform;
	public Texture2D ship1;
	public Texture2D ship2;
	public Texture2D ship3;
	public Texture2D ship4;
	public static bool RegShip;
	public static bool B2Ship;
	public static bool GoldShip;
	public static bool SpartaShip;
	string t = "This is a string inside a Scroll view! Woo Woo Woo WTF";
	
	public moveLift liftGO;
	  
	// Use this for initialization
	void Start ()
	{
	 GameObject theLift = GameObject.Find("lift");
      liftGO = theLift.GetComponent<moveLift>();
		//liftGO = gameObject.GetComponent<moveLift>();
	}
	
	// Update is called once per frame
	void OnGUI ()
	{
		//do this in 2 loops
		
		Rect DisplayRect1 = new Rect (Screen.width / 2 - 110, Screen.height / 2 - 80, 150, 50);
		Rect rect1 = new Rect (Screen.width / 2 - 110, Screen.height / 2 - 30, 50, 50);
		
		if (rect1.Contains (Input.mousePosition)) {
			GUI.Label (new Rect (DisplayRect1), "Description of Ship");
		}
          
		if (GUI.Button (rect1, ship1)) {
		  
 
			liftGO.targetPosition = new Vector3(-6.829423f,-8.070765f,10.5391f);
				
			if(liftGO.gameObject.transform.position.y == 	-8.070765f){
				Debug.Log("made it");
				liftGO.targetPosition = new Vector3(-6.831227f,-5.100811f,10.41241f);
				RegShip = true;
				B2Ship = false;
				GoldShip = false;
				SpartaShip = false;
				// GameObject.FindGameObjectWithTag("lift");
				foreach (Transform child in transform) {
					if (child.tag == "Regs") {
						child.gameObject.SetActive (true);
						//child.renderer.enabled = true;
						
						
					} else {
						//child.renderer.enabled = false;
						child.gameObject.SetActive (false);
					}
					
				}
				
			}
			
		}
		
			Rect DisplayRect2 = new Rect (Screen.width / 2 - 60, Screen.height / 2 - 80, 150, 50);
		Rect rect2 = new Rect (Screen.width / 2 - 60, Screen.height / 2 - 30, 50, 50);
		
		if (rect2.Contains (Input.mousePosition)) {
			GUI.Label (new Rect (DisplayRect2), "Description of Ship");
		}
		
		if (GUI.Button (rect2, ship2)) {
						
			RegShip = false;
			B2Ship = true;
			GoldShip = false;
			SpartaShip = false;
				
			// GameObject.FindGameObjectWithTag("lift");
			foreach (Transform child in transform) {
				if (child.tag == "B2Bomber") {
					child.gameObject.SetActive (true);
					//child.renderer.enabled = true;
					
				} else {
					//child.renderer.enabled = false;
					child.gameObject.SetActive (false);
				}
				
			}
		}
			Rect DisplayRect3 = new Rect (Screen.width / 2 - 10, Screen.height / 2 - 80,150, 50);
		Rect rect3 = new Rect (Screen.width / 2 - 10, Screen.height / 2 - 30, 50, 50);
		if (rect3.Contains (Input.mousePosition)) {
			GUI.Label (new Rect (DisplayRect3), "Description of Ship");
		}
		if (GUI.Button (rect3, ship3)) {
			
						
			RegShip = false;
			B2Ship = false;
			GoldShip = true;
			SpartaShip = false;
			foreach (Transform child in transform) {
				if (child.tag == "Goldy") {
					child.gameObject.SetActive (true);
					//child.renderer.enabled = true;
					
				} else {
					//child.renderer.enabled = false;
					child.gameObject.SetActive (false);
				}
				
			}
			
		}
		Rect DisplayRect4 = new Rect (Screen.width / 2 + 40, Screen.height / 2 - 80, 150, 50);
		Rect rect4 = new Rect (Screen.width / 2 + 40, Screen.height / 2 - 30, 50, 50);
		if (rect4.Contains (Input.mousePosition)) {
			GUI.Label (new Rect (DisplayRect4), "Description of Ship");
		}
		if (GUI.Button (rect4, ship4)) {
			
						
			RegShip = false;
			B2Ship = false;
			GoldShip = false;
			SpartaShip = true;
			
			foreach (Transform child in transform) {
				if (child.tag == "ThisIsSparta") {
					child.gameObject.SetActive (true);
					//child.renderer.enabled = true;
					
				} else {
					//child.renderer.enabled = false;
					child.gameObject.SetActive (false);
				}
				
			}
		}
		
		/*
	
	MenuX = Screen.width*0.9f;
MenuY = Screen.height*0.1f;
MenuW = Screen.width*0.1f;
MenuH = Screen.height*0.8f;
 
GUILayout.BeginArea(new Rect(MenuX,MenuY,MenuW,MenuH));
   buildMenuScrollPosition = GUILayout.BeginScrollView(buildMenuScrollPosition);
       GUILayout.BeginVertical();
           for(int i=0;i<4;i++)
           {
               //ship buttons
           }
       GUILayout.EndVertical();
   GUI.EndScrollView(); // !!!
GUILayout.EndArea();
	//////////////////////
		GUILayout.BeginHorizontal();
		scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width (200), GUILayout.Height (200));
		 GUI.skin.label.wordWrap = false;
			//	GUILayout.BeginArea(new Rect(0,0,300,300),"area");
				GUILayout.Label(t);
			GUILayout.Box("text");
		
		GUILayout.EndArea();
				GUILayout.EndScrollView();
		
				if(GUILayout.Button("Add More Text", GUILayout.Width (50), GUILayout.Height (50)))
					t += " \nAnd this is more text...........................!";
			
		
				GUILayout.EndHorizontal();
		
		
			if(GUILayout.Button("Clear"))
				t = "";
		/////////////
		
				*/		

	}
}
